/***********************************************************************
 * Module:  AbstractNetwork.java
 * Author:  Mladen
 * Purpose: Defines the Class AbstractNetwork
 ***********************************************************************/

package raf.core;

import raf.training.TrainingMethod;

public abstract class AbstractNetwork {
	public Double[] input;

	public Double[] output;

	public java.util.Collection<NetworkLayerInterface> networkLayerInterface;

	public TrainingMethod trainingMethod;

	public void trainNetwork() {
		// TODO: implement
	}

	public void initNetwork() {
		for (NetworkLayerInterface layer : networkLayerInterface) {
			layer.initialize();
		}
	}

	public java.util.Collection getNetworkLayerInterface() {
		if (networkLayerInterface == null)
			networkLayerInterface = new java.util.HashSet<NetworkLayerInterface>();
		return networkLayerInterface;
	}

	public java.util.Iterator getIteratorNetworkLayerInterface() {
		if (networkLayerInterface == null)
			networkLayerInterface = new java.util.HashSet<NetworkLayerInterface>();
		return networkLayerInterface.iterator();
	}

	public void setNetworkLayerInterface(
			java.util.Collection newNetworkLayerInterface) {
		removeAllNetworkLayerInterface();
		for (java.util.Iterator iter = newNetworkLayerInterface.iterator(); iter
				.hasNext();)
			addNetworkLayerInterface((NetworkLayerInterface) iter.next());
	}

	public void addNetworkLayerInterface(
			NetworkLayerInterface newNetworkLayerInterface) {
		if (newNetworkLayerInterface == null)
			return;
		if (this.networkLayerInterface == null)
			this.networkLayerInterface = new java.util.HashSet<NetworkLayerInterface>();
		if (!this.networkLayerInterface.contains(newNetworkLayerInterface))
			this.networkLayerInterface.add(newNetworkLayerInterface);
	}

	public void removeNetworkLayerInterface(
			NetworkLayerInterface oldNetworkLayerInterface) {
		if (oldNetworkLayerInterface == null)
			return;
		if (this.networkLayerInterface != null)
			if (this.networkLayerInterface.contains(oldNetworkLayerInterface))
				this.networkLayerInterface.remove(oldNetworkLayerInterface);
	}

	public void removeAllNetworkLayerInterface() {
		if (networkLayerInterface != null)
			networkLayerInterface.clear();
	}

	public TrainingMethod getTrainingMethod() {
		return trainingMethod;
	}

	public void setTrainingMethod(TrainingMethod newTrainingMethod) {
		trainingMethod = newTrainingMethod;
	}
}